package demo1;

import java.util.*;

@SuppressWarnings({"all"})
public class test {
    public static void main(String[] args) {
        Map map = new HashMap();
        map.put("jack",650);
        map.put("tom",1200);
        map.put("smith",2900);
        System.out.println("变化前的情况：");
        System.out.println(map);


        System.out.println("替换为2600之后的情况：");
        map.put("jack",2600);
        System.out.println(map);


        Set set = map.keySet();
        for (Object key : set) {
            //这个地方需要进行向下转型
            map.put(key,(Integer)map.get(key)+100);
        }
        System.out.println("薪水加上100之后的情况：");
        System.out.println(map);

        System.out.println("=====迭代器while循环遍历员工=====");
        Set entryset = map.entrySet();
        Iterator iterator = entryset.iterator();
        while (iterator.hasNext()) {
            Map.Entry entry =  (Map.Entry)iterator.next();
            System.out.println(entry.getKey()+"-"+entry.getValue());
        }

        System.out.println("======工资======");
        Collection values = map.values();
        for (Object value : values) {
            System.out.println(value);
        }
    }
}
